Find the first repeated characterΒΆ
Find the first repeated character in a given string.
def first_repeated_char(S):
for index, c in enumerate(S):
if S[:index+1].count(c) > 1:
return c
return "None"
print(first_repeated_char("abcdabcd")) # a
print(first_repeated_char("abcd")) # None